<?php

namespace App\DefaultBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;
use Behat\MinkExtension\Context\RawMinkContext;

use Behat\Behat\Context\ClosuredContextInterface,
    Behat\Behat\Context\TranslatedContextInterface,
    Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
    Behat\Gherkin\Node\TableNode;
use Behat\Behat\Context\Step\Given,
    Behat\Behat\Context\Step\When,
    Behat\Behat\Context\Step\Then;

use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Symfony\Component\HttpKernel\KernelInterface;

use App\MoonBundle\Service\MoonPhaseService;


require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';

class DefaultContext extends RawMinkContext implements KernelAwareInterface
{
    public function __construct()
    {
        $this->useContext('mink', new MinkContext());
    }

    /**
     * @var \Symfony\Component\HttpKernel\KernelInterface $kernel
     */
    private $kernel = null;

    /**
     * @param \Symfony\Component\HttpKernel\KernelInterface $kernel
     *
     * @return null
     */
    public function setKernel(KernelInterface $kernel)
    {
        $this->kernel = $kernel;
    }

    protected function getContainer()
    {
        return $this->kernel->getContainer();
    }

    /**
     * @Then /^I should see today moon day$/
     */
    public function iShouldSeeTodayMoonDay()
    {
        $moon = new MoonPhaseService();

        // var_dump($this->fixStepArgument($moon->age())); die;

        $this->assertSession()->pageTextContains($this->fixStepArgument($moon->age()));
    }
}